/********************************************************************
	created:	2/10/2005   3:25
	filename: 	camera.h
	author:		GMKal (exile79@gmail.com)
	
	purpose:	first-person walking camera

    last modified:	 9/11/2005   3:25 
*********************************************************************/


#pragma once
#include "glmath.h"
#include "PosObject.h"
using namespace glmath;


class Camera
{
public:

	Camera();

	double	mPitchRate;	
	double	mHeadingRate;
	double	mHeadingRads;
	double	mPitchRads;
	float	mMaxForwardVelocity;
	float	mForwardVelocity;
	float	mUpdownVelocity;
	
	enum Mode { Walking, Flying };
	
	Mode mMode;

	Quaternion mHeading;
	Quaternion mPitch;
	Vector3 mPosition;
	Vector3 mView;
	Vector3 mUp;

	
	void Init();
	void Update(CView* pview,double dt);
	void Apply();

	void RotateByMouse(int mousex,int mousey,int midx,int midy,double dt);
	float ChangeVelocity(float vel);
	void SetVelocity(float vel);
	void ChangeHeading(double rads);
	void ChangePitch(double rads);
	void SetHeading(double rads);
	void SetPitch(double rads);
	void SetPerspective();
	void SetView(const Vector3& view);
	void SetView(float x,float y,float z);
	void SetPosition(const Vector3& position);
	void SetPosition(float x,float y,float z);
	void Update(Vector3 v,float vel);
	void Move(float vel);
	void Strafe(float vel);
	void Elevate(float vel);

	const Vector3& GetPosition() { return mPosition;	}
	const Vector3& GetView() { return mView;	}

};


//class cController;

//class cCamera
//{
//public:
//	cCamera(void);
//	
//
//	void Update(double time);
//	void Init(	CView *view,
//				float newSpeed,
//				Vector3 newPosition=Vector3(0.0f,0.0f,0.0f),
//				float newAngleYaw=0.0f, float newAnglePitch=0.0f);
//	void Apply();
//
//	CView*		m_pview;
//	Vector3		mPosition;
//	float		m_angleHeading;	//yaw
//	float		m_anglePitch;
//	float		m_speed;
//};
//
//
//
//
//
//
///*
// *	a flying camera
// *	heading and pitch -- no roll...
// *	not functional...
// */
//class cQuatCamera : public cPosObject
//{
//public:
//	// Vector3 mPosition;
//	// Vector3 mView;
//	// Vector3 mUp;
//
//	CView*	m_pView;
//	float	mPitchRate;
//	float	mHeadingRate;
//	//float	m_angleHeading;
//	//float	m_anglePitch;
//	//float	m_maxSpeed;
//	float	m_speed;
//
//	//Quaternion qHeading;
//	//Quaternion qPitch;
//
//	cQuatCamera(Vector3 &position=Vector3(0,0,0),
//				double	angleHeading=0.0, double anglePitch=0.0);
//	
//
//	void Update(const CView* pview, double dt);
//	void Init(	Vector3 &position,
//				double	angleHeading, double anglePitch);
//	void Apply();
//
//#ifdef _DEBUG
//	void Test();
//#endif
//};
//
//
//
//class cFlyingCamera
//{
//	Vector3		m_pos;			// Camera position.
//	Vector3		mView;			// Look at position.
//	Vector3		mUp;	        // Up direction.
//	Vector3		m_strafe;       // Strafe direction.
//	float		m_currentRotationAngle; // Keeps us from going too far up or down.
//	//float frameInterval;        // Used with time based movements.
//
//
//	cFlyingCamera();
//	void Init(	Vector3 &position,       // Set the camera's position.
//				Vector3 &view,
//				Vector3 &up);
//
//	void Move(float direction);               // Move the camera forwards and backwards.
//	void Update(Vector3 Dir, float speed);    // Update the camera's position.
//	void Strafe(float direction);
//	void CalculateStrafe();                         // Calculate the direction of the strafe.
//	void Rotate(float AngleDir, float xSpeed, // Rotate the camera around the view.
//		float ySpeed, float zSpeed);
//	void Rotate(Vector3 point, float AngleDir,// Rotate the camera around a point.
//		float xSpeed, float ySpeed, float zSpeed);
//	void RotateByMouse(int mousePosX, int mousePosY,
//		int midX, int midY);         // Rotate camera by mouse.
//	
//};